package com.david.course_design.shopping_center.module.user.mapper;

import com.david.course_design.shopping_center.module.login.VO.LoginVo;
import com.david.course_design.shopping_center.module.login.VO.RegisterVo;
import com.david.course_design.shopping_center.module.user.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import tk.myBatis.mapper.MyBaseMapper;

@Component
public interface UserMapper extends MyBaseMapper<User> {
    /**
     * 这个接口为登录服务判断登录账号密码是否正确
     *
     * @param loginVo
     * @return
     */
    @Select("<script>" +
            "SELECT \n" +
            "    *\n" +
            "FROM\n" +
            "    t_user \n" +
            "WHERE\n" +
            "    1 = 1 " +
            "    AND name = #{name}\n" +
            "    AND password = #{password}" +
            "</script>"
    )
    LoginVo LoginInterface(LoginVo loginVo);

    @Insert("INSERT INTO t_user (`name`, `password`) VALUES (#{ name }, #{ password });")
    Integer RegisterInterface(RegisterVo registerVo);
}